package com.undsf.despot.templates;

import com.undsf.despot.CombatContext;
import com.undsf.despot.modles.Metadata;
import com.undsf.despot.modles.Monster;
import com.undsf.despot.modles.Skill;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Arathi on 2016/10/4.
 */
public class MonsterTemplateBase {
    // Unit的属性
    protected Integer id;
    protected String name;
    protected String cnname;
    protected Integer hp;
    protected Integer mp;
    protected Integer attack;
    protected Integer defense;
    protected Integer speed;
    protected Integer evasion;
    protected Integer intellect;
    protected Integer exp;
    protected Integer gold;
    protected Map<String, Integer> resistances;

    // Monster的属性
    protected List<String> actions;
    protected int actionMode;

    // 技能表
    protected List<String> skills;

    public int getID() {
        return id;
    }

    /**
     * 通过模板创建Monster实例
     */
    public Monster create() {
        Monster monster = new Monster();

        monster.setId(id);
        monster.setName(cnname);
        monster.setHpMax(hp);
        monster.setHp(hp);
        monster.setMpMax(mp);
        monster.setMp(mp);
        monster.setAttack(attack);
        monster.setDefense(defense);
        monster.setSpeed(speed);
        monster.setEvasion(evasion);
        monster.setIntellect(intellect);
        monster.setExp(exp);
        monster.setGold(gold);
        monster.setResistances(resistances);
        monster.setActions(actions);
        monster.setActionMode(actionMode);

        List<Skill> mskills = new ArrayList<Skill>();
        for (String skillId : skills) {
            Skill skill = Metadata.GetCommonMetadata().createSkill(skillId);
            mskills.add(skill);
        }
        monster.setSkills(mskills);

        return monster;
    }

    public String getNumber() {
        String number = "No.";
        if (id<10) number += "0";
        number += id;
        return number;
    }

    @Override
    public String toString() {
        return getNumber() + " " + cnname;
    }
}
